﻿@model CommerceOne.Widgets.LeftCategoryNav.LeftCategoryViewModel

<div id="categories_block_left" class="block">
    <h4>
        Categories</h4>
    <div class="block_content">
        <ul class="tree dhtml">

        @if (Model.ProductCategories != null)
        {
            var counting = 1;
            foreach (var item in Model.ProductCategories)
            {
                if (counting == Model.ProductCategories.Count)
                {
                    <li class="last"><a href="@item.Url" title="">@item.Name</a> </li>
                }
                else
                {
                    <li><a href="@item.Url" title="">@item.Name</a> </li>
                }
                counting++;

                if (item.ChildCategory != null && item.ChildCategory.Count > 0)
                {
                     <ul>
                    @{var countingChild = 1; }
                    @foreach (var chidlItem in item.ChildCategory)
                    {
                        if (countingChild == item.ChildCategory.Count)
                        {
                            <li class="last"><a href="@chidlItem.Url" title="">@chidlItem.Name</a>  </li>
                        } 
                        else
                        {
                            <li><a href="@chidlItem.Url" title="">@chidlItem.Name</a>  </li>
                        }
                        countingChild++;
                    }
                    </ul>
                }
            }
        }
        </ul>
        <script type="text/javascript">
		// <![CDATA[
            // we hide the tree only if JavaScript is activated
            // $('div#categories_block_left ul.dhtml').hide();
		// ]]>
        </script>
    </div>
</div>
